<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/pages/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>广东工业大学招生办</title>
<link rel="stylesheet" type="text/css" href="${ctx }/css/reset.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/css/common.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/css/system.css" />

<script type="text/javascript" src="${ctx }/js/jquery.min.js"></script>
 <script type="text/javascript" src="${ctx }/My97DatePicker/WdatePicker.js"></script> 

   
<script type="text/javascript">
function checkMessage(){
	var regu = "^[0-9a-zA-Z]+$"; 
	var re = new RegExp(regu); 
	var name = $("#userName").attr("value"),
		sfz = $("#userIdentify").attr("value"),
		//userBirth = date.replace(/[^0-9]/ig,""),
		userBirth = $("#Wdate").attr("value"),
		phone = $("#userPhone").attr("value"),
		email = $("#userEmail").attr("value"),
		pwd1 = $("#userPassword1").attr("value"),
		pwd2 = $("#userPassword2").attr("value");
	
	userBirth = userBirth.replace(/[^0-9]/ig,"");
	var myReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
		$.post("${ctx }/base/examinee!checkIdentity.action", {userIdentify:sfz}, function(text) {
					//$("#checkIdentity").val(text);
					if(text=="false"){
						alert("该身份证号已被注册，请勿重复注册");
						}
					else
						{
						if(name.length<2 || name.length >20){
							alert("姓名长度要求在 2 与 20 之间");
							return false;
						} if(sfz.length<18){
							alert("身份证号码的长度必须为18位");
							return false;
						}
						/* else 
						if($("#checkIdentity").val()=="false"){ 
							alert("该身份证已被注册");
							return false;
						} */
						 if(sfz.substr(6,8) != userBirth){
							alert("出生日期必须与身份证日期相符");
							return false;
						} if(phone.length<5 || phone.length>30){
							alert("联系电话长度要求在 5 与 30 之间");
							return false;
						} if(email.length<5 || email.length>30){		
							alert("电子邮件长度要求在 5 与 30 之间");
							return false;
						} if(!myReg.test(email)) {
							alert("电子邮箱格式错误");
							return false;
						} if(pwd1.length<6 || pwd1.length >20){
							alert("密码长度要求在 5 与 20 之间");
							return false;
						} if(pwd1 != pwd2){
							alert("两次输入的密码必须相同");
							return false;
						}else{
							$(".validateTips").html("");
							$("#playerRegister").submit();
							alert("注册成功");
							return true;
						}
						
						}
					
			});
		
	
	
}

  	function isNumberOrLetter(){//判断是否是数字或字母 
		var regu = "^[0-9a-zA-Z]+$"; 
		var sfz = $("#userIdentify").attr("value");
		var re = new RegExp(regu); 
		if (re.test(sfz)) { 
			//$(".validateTips").html("");
			$.post("${ctx }/base/examinee!checkIdentity.action", {userIdentify:sfz}, function(text) {
						$("#checkIdentity").val(text);
				});
			return true; 
		}else{ 
			//$("#userIdentify").parent().siblings(".tips").html("身份证号码只能为数字或者字母");
			$(".validateTips").html("身份证号码只能为数字或者字母");
			return false;
		};
	}
  	
  	
  	
  	function checkId(){
  		var sfz = $("#userIdentify").attr("value");
  		$.post("${ctx }/base/examinee!checkIdentity.action", {userIdentify:sfz}, function(text) {
			if(text=="false"){
				alert("该身份证号已被注册，请勿重复注册");
				return false;
			}
				else
					return true;
			
	});
}
  		
  		
  	
	/*
	function isEmail(){ //检查输入对象的值是否符合E-Mail格式
		//var myReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/; 
		var myReg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; 
		var email = $("#userEmail").attr("value");
		//alert(email);
		if(myReg.test(email)) {
			//$(".validateTips").html("");
			return true; 
		}else{ 
			//$("#userEmail").parent().siblings(".tips").html("电子邮箱格式错误");
			$(".validateTips").html("电子邮箱格式错误");
			return false;
		};
	}
	*/
	</script>

</head>

<body onload="document.forms.playerRegister.userName.focus()">
	<div class="wrapper">
		<div class="center-content auto rel">
			<div class="center-content-title f16">
				<h1 class="rel">广工大<s:property value="endTime.substring(0,4)"/>年高水平运动员报名系统——系统注册</h1>
			</div>
			<div class="center-content-txt f14">
				<div class="r mr20 mt20">
					若已有账号，请<a href="${ctx }/base/examinee!checkOnlineConsult.action" class="red">登录</a>
				</div>
				<div class="clearfix" id="checkIdentity"></div>
				<form name="playerRegister" id="playerRegister"
					action="${ctx }/base/examinee!save.action" method="post">
					<div class="validateTips tc mt20"></div>
					<input type="hidden" name="isFirstLogin" value="1"/>
					<table class="reg">
						<tr>
							<td class="tc">姓名：</td>
							<td><input type="text" name="examinee.name" id="userName"
								class="" />
							</td>
							<td></td>
						</tr>
						<tr>
							<td class="tc">身份证号：</td>
							<td><input type="text" name="examinee.identity"
								id="userIdentify" class=""  maxlength="18" onKeyup="return checkId();" onclick="return checkId();"/>
							</td>
							<td class="tips">必须为18位的身份证号码</td>
						</tr>
						<tr>
							<td class="tc">出生日期：</td>
							<td id="userBirth"><input class="Wdate" type="text" onClick="WdatePicker()" id="Wdate" name="examinee.birthday" onclick="return checkId();"/></td>
							<td class="tips">格式样例：1990-01-01</td>
						</tr>
						<tr>
							<td class="tc">联系电话：</td>
							<td><input type="text" name="examinee.phone" id="userPhone"	class="" onclick="return checkId();"/>
							</td>
						</tr>
						<tr>
							<td class="tc">电子邮箱：</td>
							<td><input type="text" name="examinee.email" id="userEmail"	class=""  onclick="return checkId();"/>
							</td>
							<td class="tips">格式样例：test@126.com</td>
						</tr>
						<tr>
							<td class="tc">密码：</td>
							<td><input type="password" name="examinee.password"
								id="userPassword1" class="" onclick="return checkId();"/>
							</td>
						</tr>
						<tr>
							<td class="tc">再次输入密码：</td>
							<td><input type="password" name="" id="userPassword2"
								class="" onclick="return checkId();"/>
							</td>
							<td class="tips">必须与上面的密码一致</td>
						</tr>
					</table>
					
					<p class="tips ml20 mr20 mb20">注意：注册后姓名、身份证密码以及出生日期将不得再修改，提交前请仔细检查！</p>
					<button type="button" class="r mr10 button mt20" onclick="window.location.href='${ctx}/'">
						<span>取消</span>
					</button>
					<button type="button" class="r button mr10 mb20 mt20" onclick="return checkMessage();">
						<span>确定</span>
					</button>
					<div class="clearfix"></div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
